<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Muse","version":"8.6.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta name="description" content="Linux 常用命令文件操作命令mkdir命令   功能简介：创建文件夹    常用组合：   mkdir   test   #创建一级文件夹test   mkdir -p  test&#x2F;test1&#x2F;test2  #创建多级目录">
<meta property="og:type" content="article">
<meta property="og:title" content="Linux">
<meta property="og:url" content="http://example.com/2021/08/01/Linux/index.html">
<meta property="og:site_name" content="风轻云淡">
<meta property="og:description" content="Linux 常用命令文件操作命令mkdir命令   功能简介：创建文件夹    常用组合：   mkdir   test   #创建一级文件夹test   mkdir -p  test&#x2F;test1&#x2F;test2  #创建多级目录">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-08-01T09:19:17.000Z">
<meta property="article:modified_time" content="2021-08-22T05:41:25.780Z">
<meta property="article:author" content="WQQ">
<meta property="article:tag" content="风">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://example.com/2021/08/01/Linux/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://example.com/2021/08/01/Linux/","path":"2021/08/01/Linux/","title":"Linux"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Linux | 风轻云淡</title>
  




  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
	<!-- 页面点击小红心 -->
	<script type="text/javascript" src="/js/src/clicklove.js"></script>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">风轻云淡</h1>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">清风吹拂，白云淡淡</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-首页"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-关于"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li>
        <li class="menu-item menu-item-标签"><a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a></li>
        <li class="menu-item menu-item-分类"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
  </ul>
</nav>




</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#Linux-%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4"><span class="nav-number">1.</span> <span class="nav-text">Linux 常用命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%96%87%E4%BB%B6%E6%93%8D%E4%BD%9C%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.</span> <span class="nav-text">文件操作命令</span></a><ol class="nav-child"><li class="nav-item nav-level-6"><a class="nav-link" href="#mkdir%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.1.</span> <span class="nav-text">mkdir命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#cp%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.2.</span> <span class="nav-text">cp命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#touch%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.3.</span> <span class="nav-text">touch命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#mv%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.4.</span> <span class="nav-text">mv命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#rm%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.5.</span> <span class="nav-text">rm命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#ls%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.6.</span> <span class="nav-text">ls命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#cat%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.7.</span> <span class="nav-text">cat命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#pwd-%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.8.</span> <span class="nav-text">pwd 命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#tar%E8%A7%A3%E5%8E%8B%E7%BC%A9"><span class="nav-number">1.1.0.0.9.</span> <span class="nav-text">tar解压缩</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#cd%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.10.</span> <span class="nav-text">cd命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#clear%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.11.</span> <span class="nav-text">clear命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#free%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.12.</span> <span class="nav-text">free命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#chmod-%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.13.</span> <span class="nav-text">chmod 命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#df-%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.14.</span> <span class="nav-text">df 命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#sz%E5%91%BD%E4%BB%A4%EF%BC%8Crz%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.15.</span> <span class="nav-text">sz命令，rz命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#grep%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.16.</span> <span class="nav-text">grep命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#jps%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.17.</span> <span class="nav-text">jps命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#sed%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.18.</span> <span class="nav-text">sed命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#tail%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.19.</span> <span class="nav-text">tail命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#head-%E5%91%BD%E4%BB%A4"><span class="nav-number">1.1.0.0.20.</span> <span class="nav-text">head 命令</span></a></li><li class="nav-item nav-level-6"><a class="nav-link" href="#cat%E5%91%BD%E4%BB%A4-1"><span class="nav-number">1.1.0.0.21.</span> <span class="nav-text">cat命令</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-overview">
            <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="WQQ"
      src="/images/aaa.jpg">
  <p class="site-author-name" itemprop="name">WQQ</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives">
          <span class="site-state-item-count">14</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">1</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://gitee.com/wqqszz" title="GitHub → https:&#x2F;&#x2F;gitee.com&#x2F;wqqszz" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="QQ:1640611853@qq.com" title="E-Mail → QQ:1640611853@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



          </div>
        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://example.com/2021/08/01/Linux/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/aaa.jpg">
      <meta itemprop="name" content="WQQ">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="风轻云淡">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Linux
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-08-01 17:19:17" itemprop="dateCreated datePublished" datetime="2021-08-01T17:19:17+08:00">2021-08-01</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-08-22 13:41:25" itemprop="dateModified" datetime="2021-08-22T13:41:25+08:00">2021-08-22</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/Linux/" itemprop="url" rel="index"><span itemprop="name">Linux</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h2 id="Linux-常用命令"><a href="#Linux-常用命令" class="headerlink" title="Linux 常用命令"></a>Linux 常用命令</h2><h3 id="文件操作命令"><a href="#文件操作命令" class="headerlink" title="文件操作命令"></a>文件操作命令</h3><h6 id="mkdir命令"><a href="#mkdir命令" class="headerlink" title="mkdir命令"></a>mkdir命令</h6><table>
<thead>
<tr>
<th>功能简介：创建文件夹</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>mkdir   test   #创建一级文件夹test</td>
</tr>
<tr>
<td>mkdir -p  test/test1/test2  #创建多级目录</td>
</tr>
</tbody></table>
<span id="more"></span>



<h6 id="cp命令"><a href="#cp命令" class="headerlink" title="cp命令"></a>cp命令</h6><table>
<thead>
<tr>
<th>功能简介：copy复制拷贝命令</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>cp  目标文件    指定路径</td>
</tr>
<tr>
<td>cp  -r  目标文件  指定路径 #当前文件夹下有内容时，会进行递归复制，直到把整个目录复制完成</td>
</tr>
</tbody></table>
<h6 id="touch命令"><a href="#touch命令" class="headerlink" title="touch命令"></a>touch命令</h6><table>
<thead>
<tr>
<th>功能简介：创建一个文件</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合</td>
</tr>
<tr>
<td>touch   test.properties  #创建一个配置文件</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="mv命令"><a href="#mv命令" class="headerlink" title="mv命令"></a>mv命令</h6><table>
<thead>
<tr>
<th>功能简介：移动文件到指定位置，或者改变修改文件名</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>mv   原文件   新文件名  #修改文件名</td>
</tr>
<tr>
<td>mv  原文件    指定路径  #移动</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="rm命令"><a href="#rm命令" class="headerlink" title="rm命令"></a>rm命令</h6><table>
<thead>
<tr>
<th>功能简介：删除命令</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合</td>
</tr>
<tr>
<td>rm -r #递归删除</td>
</tr>
<tr>
<td>rm -f #强制删除</td>
</tr>
<tr>
<td>rm -rf #强制递归删除</td>
</tr>
</tbody></table>
<h6 id="ls命令"><a href="#ls命令" class="headerlink" title="ls命令"></a>ls命令</h6><table>
<thead>
<tr>
<th>功能简介：查看列出当前目录下的所有文件和文件夹</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>ls       #列出当前目录下的所有文件，文件夹（不包括隐藏文件）</td>
</tr>
<tr>
<td>ls -a  #列出目录下的所有文件，包括 以 ‘.’ 结尾的隐藏文件</td>
</tr>
<tr>
<td>ls -l   #除了文件名之外，还将文件的权限，所有者，文件大小等信息列出来</td>
</tr>
<tr>
<td>ls  -al  #列出所有文件，文件夹，隐藏文件的详细信息</td>
</tr>
</tbody></table>
<h6 id="cat命令"><a href="#cat命令" class="headerlink" title="cat命令"></a>cat命令</h6><table>
<thead>
<tr>
<th>功能简介：显示文件里的内容，创建文件编辑文件内容</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>cat    xxx.properties  #查看properties文件内容</td>
</tr>
<tr>
<td>cat  &gt;  test.txt #创建test.txt文件编辑文件内容</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="pwd-命令"><a href="#pwd-命令" class="headerlink" title="pwd 命令"></a>pwd 命令</h6><table>
<thead>
<tr>
<th>功能简介：查看当前所在位置的路径</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>pwd</td>
</tr>
</tbody></table>
<h6 id="tar解压缩"><a href="#tar解压缩" class="headerlink" title="tar解压缩"></a>tar解压缩</h6><table>
<thead>
<tr>
<th>常用命令组合：</th>
</tr>
</thead>
<tbody><tr>
<td>//解压gzip文件 :             tar -zxvf  ****.tar.gz</td>
</tr>
<tr>
<td>//解压 tar文件 :              tar -xvf   ****.tar</td>
</tr>
<tr>
<td>tar -cvf  /home/www/</td>
</tr>
</tbody></table>
<h6 id="cd命令"><a href="#cd命令" class="headerlink" title="cd命令"></a>cd命令</h6><table>
<thead>
<tr>
<th>功能简介：更换当前目录</th>
</tr>
</thead>
<tbody><tr>
<td>常用组合：</td>
</tr>
<tr>
<td>cd  /   #到系统根目录</td>
</tr>
<tr>
<td>cd ../  #到上一级目录</td>
</tr>
<tr>
<td>cd -    #到上一次工作的目录</td>
</tr>
<tr>
<td>cd ~  # 到当前用户的主目录</td>
</tr>
</tbody></table>
<h6 id="clear命令"><a href="#clear命令" class="headerlink" title="clear命令"></a>clear命令</h6><table>
<thead>
<tr>
<th>功能简介：清空命令</th>
</tr>
</thead>
<tbody><tr>
<td>clear</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="free命令"><a href="#free命令" class="headerlink" title="free命令"></a>free命令</h6><table>
<thead>
<tr>
<th>功能简介：显示系统内存使用情况，包括物理内存，以及交换区内存</th>
</tr>
</thead>
<tbody><tr>
<td>free -m #以M为单位</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="chmod-命令"><a href="#chmod-命令" class="headerlink" title="chmod 命令"></a>chmod 命令</h6><table>
<thead>
<tr>
<th>功能简介：授权命令</th>
</tr>
</thead>
<tbody><tr>
<td><strong>chmod命令</strong>用来变更文件或目录的权限</td>
</tr>
<tr>
<td>Linux用 户分为：拥有者、组群(Group)、其他（other）</td>
</tr>
<tr>
<td>r ：读取权限，代表数字为4  ， w：写权限，代表数字2 ，x:执行权限，代表数字 1</td>
</tr>
<tr>
<td>chmod 777 #授予拥有者/组群/其他为读，写，执行权限</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="df-命令"><a href="#df-命令" class="headerlink" title="df 命令"></a>df 命令</h6><table>
<thead>
<tr>
<th>功能简介：<strong>df命令</strong>用于显示磁盘分区上的可使用的磁盘空间</th>
</tr>
</thead>
<tbody><tr>
<td>df(选项)(参数)</td>
</tr>
<tr>
<td>df -h  #场景，查看RocketMq磁盘使用空间</td>
</tr>
</tbody></table>
<h6 id="sz命令，rz命令"><a href="#sz命令，rz命令" class="headerlink" title="sz命令，rz命令"></a>sz命令，rz命令</h6><table>
<thead>
<tr>
<th>将选定的文件发送（send）到本地机器:</th>
</tr>
</thead>
<tbody><tr>
<td>sz  fileName     #如果没有找到这个命令，执行安装命令：yum install lrzsz</td>
</tr>
<tr>
<td>rz    #如果没有找到这个命令，执行安装命令：yum install lrzsz</td>
</tr>
</tbody></table>
<h6 id="grep命令"><a href="#grep命令" class="headerlink" title="grep命令"></a>grep命令</h6><table>
<thead>
<tr>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody></table>
<h6 id="jps命令"><a href="#jps命令" class="headerlink" title="jps命令"></a>jps命令</h6><table>
<thead>
<tr>
<th>用来查看本地运行着几个java程序，并显示他们的进程号。使用jps时，不需要传递进程号作为参数。</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody><tr>
<td>jps [选项] [参数]</td>
<td></td>
<td></td>
</tr>
<tr>
<td>如果jps命令无法找到，需要安装openjdk-devel包<br/>    yum install -y java-1.8.0-openjdk-devel.x86_64</td>
<td></td>
<td></td>
</tr>
<tr>
<td>查看jps命令是否存在   which jps</td>
<td></td>
<td></td>
</tr>
</tbody></table>
<h6 id="sed命令"><a href="#sed命令" class="headerlink" title="sed命令"></a>sed命令</h6><table>
<thead>
<tr>
<th>sed 根据日期查询日志；特别说明:上面的两个日期必须是日志中打印出来的日志,否则无效；</th>
</tr>
</thead>
<tbody><tr>
<td>sed -n ‘/开始日期/,/结束日期/p’  test.log</td>
</tr>
<tr>
<td>sed -n ‘/2014-12-17 16:17:20/,/2014-12-17 16:17:36/p’ test.log</td>
</tr>
</tbody></table>
<h6 id="tail命令"><a href="#tail命令" class="headerlink" title="tail命令"></a>tail命令</h6><table>
<thead>
<tr>
<th>tail命令从尾部查看日志；tail是看后多少行日志；例子如下：</th>
</tr>
</thead>
<tbody><tr>
<td>-n  是显示行号</td>
</tr>
<tr>
<td>tail -200f test.log   #实时监控200行日志</td>
</tr>
<tr>
<td>tail -n 100 test.log  #查询日志尾部最后100行日志</td>
</tr>
<tr>
<td>tail -n +100 test.log #查询100行之后的日志</td>
</tr>
<tr>
<td>扩展：tail -n 100 test.log | grep ‘查询字符串’  # 查询尾部100行里指定的’字符串‘</td>
</tr>
<tr>
<td>tail -n 100 test.log |  grep ‘查询字符串’ -C 100   #查询字符串上线指定行数</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
<h6 id="head-命令"><a href="#head-命令" class="headerlink" title="head 命令"></a>head 命令</h6><table>
<thead>
<tr>
<th>head 命令从头部查看日志；与tail相反</th>
</tr>
</thead>
<tbody><tr>
<td>-n  是显示行号</td>
</tr>
<tr>
<td>head -n 10 test.log #查看日志文件头10行日志</td>
</tr>
<tr>
<td>head -n -10 test.log #查询日志文件除了最后10行的其他所有日志;</td>
</tr>
<tr>
<td>扩展：head -n 100 test.log  | grep ‘查询字符串’ #查询日志文件头100行里指定字符串</td>
</tr>
<tr>
<td>head -n 100 test.log | grep ‘指定字符串’ -C  100</td>
</tr>
</tbody></table>
<h6 id="cat命令-1"><a href="#cat命令-1" class="headerlink" title="cat命令"></a>cat命令</h6><table>
<thead>
<tr>
<th>cat 从上往下查看日志</th>
</tr>
</thead>
<tbody><tr>
<td>-n  行</td>
</tr>
<tr>
<td>cat  -n test.log | grep ‘字符串’   #查询打印指定’字符串‘的所在行号</td>
</tr>
<tr>
<td>扩展：分页打印日志</td>
</tr>
<tr>
<td>cat -n test.log | grep ‘字符串’ | more  # 这样就分页打印了,通过点击空格键翻页</td>
</tr>
<tr>
<td>cat -n test.log | grep ‘字符串’ &gt; test.txt  # 将查出来的日志复制放在test.txt文件中</td>
</tr>
<tr>
<td>扩展：tac 命令，从下往上打印日志，用发同cat</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>

    </div>

    
    
    
	
	<div>
		
			<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
		
	</div>

    <footer class="post-footer">

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/2021/07/24/categories/" rel="prev" title="categories">
                  <i class="fa fa-chevron-left"></i> categories
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/2021/08/13/docker/" rel="next" title="Docker">
                  Docker <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">WQQ</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script>

  




  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>





<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
